import { request } from '@umijs/max';

// 上传文件
export async function FileUpload(options){
    return request('/api/file/documentupload/',
      {
        method:'post',
        data:options
      }
    )
  }

  // 预览文件
export async function GetFile(data){
    const {id='',file_name='',file_type='',uploaded_at__gte='',uploaded_at__lte='',user=''} = data
 
    return request(`/api/file/document/?id=${id}&file_name=${file_name}&file_type=${file_type}&uploaded_at__gte=${uploaded_at__gte}&uploaded_at__lte=${uploaded_at__lte}&user=${user}`,
      {
        method:'get'
      }
    )
}

// 删除文件
export async function DeleteFile(id){
    return request(`/api/file/document/${id}/`,
        {
            method:'delete'
        }
    )
}

// 批量下载文件
export async function DownloadFiles(ids){
    return request(`/api/file/DownloadFiles/`,
        {
            method:'post',
            responseType: 'arraybuffer',
            data:ids
        }
    )
}